import { getLevelFirst, getLevelZero, getUserID } from '@/utils';

const MaterialManageTabSwitch = (curRes: Record<string, any>) => {
  const MaterialManageTab = () => {
    if (curRes?.['/materialController/createCompanyID']) {
      return {
        createCompanyID: getLevelZero(),
        params: 'createCompanyID',
        key: 'MaterialManageTabKey',
      };
    } else if (curRes?.['/materialController/createDepartmentID']) {
      return {
        createDepartmentID: getLevelFirst(),
        params: 'createDepartmentID',
        key: 'MaterialManageTabKey',
      };
    } else if (curRes?.['/materialController/createrID']) {
      return {
        createrID: getUserID(),
        params: 'createrID',
        key: 'MaterialManageTabKey',
      };
    }
  };

  const MyMaterialCheckTab = () => {
    if (curRes?.['/materialController/myMaterialCheck']) {
      return {
        createCompanyID: getLevelZero(),
        params: 'createCompanyID',
        key: 'MyMaterialCheckTabKey',
        state: 1,
      };
    }
  };

  return [
    {
      title: '物料管理',
      key: 'MaterialManageTabKey',
      visible:
        (curRes?.['/materialController/createCompanyID'] || curRes?.['/materialController/createDepartmentID'] || curRes?.['/materialController/createrID']) ??
        false,
      md: 2,
      sm: 24,
      params: MaterialManageTab(),
    },
    {
      title: '我的审核',
      key: 'MyMaterialCheckTabKey',
      visible: curRes?.['/materialController/myMaterialCheck'] ?? false,
      md: 2,
      sm: 24,
      params: MyMaterialCheckTab(),
    },
  ];
};

export { MaterialManageTabSwitch };
